package so.sao.shop.supplier.pojo.vo;

import so.sao.shop.supplier.util.NumberUtil;
import so.sao.shop.supplier.util.StringAndDateUtil;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 结算明细出参Vo
 * @author wenchao.nie
 * @date 2017/07/24
 */
public class OrderMoneyRecordVo {
    /**
     * 结算明细id
     */
    private String recordId;

    /**
     * 供应商名称
     */
    private String providerName;

    /**
     * 结账时间
     */
    private Date checkoutAt;

    /**
     * 待结算金额
     */
    private BigDecimal totalMoney;

    /**
     * 已结算金额
     */
    private BigDecimal settledAmount;

    /**
     * 结算时间
     */
    private Date settledAt;

    /**
     * 结算状态 0 待结算 1 已结算
     */
    private String state;

    /**
     * 银行卡号
     */
    private String bankAccount;

    /**
     * 银行流水号
     */
    private String serialNumber;

    /**
     * 运费总金额
     */
    private BigDecimal postageTotalAmount;

    /**
     * 订单总金额
     */
    private BigDecimal orderTotalAmount;

    /**
     * 是否核账 0：否，1：是
     */
    private Integer whetherCheckAccount;

    public String getRecordId() {
        return recordId;
    }

    public void setRecordId(String recordId) {
        this.recordId = recordId;
    }

    public String getProviderName() {
        return providerName;
    }

    public void setProviderName(String providerName) {
        this.providerName = providerName;
    }

    public String getCheckoutAt() {
        return checkoutAt == null ? "" : StringAndDateUtil.fomateData(checkoutAt, "yyyy-MM-dd");
    }

    public void setCheckoutAt(Date checkoutAt) {
        this.checkoutAt = checkoutAt;
    }

    public BigDecimal getTotalMoney() {
        return totalMoney;
    }

    public void setTotalMoney(BigDecimal totalMoney) {
        this.totalMoney = totalMoney;
    }

    public BigDecimal getSettledAmount() {
        return settledAmount;
    }

    public void setSettledAmount(BigDecimal settledAmount) {
        this.settledAmount = settledAmount;
    }

    public String getSettledAt() {
        return settledAt == null ? "" : StringAndDateUtil.fomateData(settledAt, "yyyy-MM-dd HH:mm");
    }

    public void setSettledAt(Date settledAt) {
        this.settledAt = settledAt;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getBankAccount() {
        return bankAccount;
    }

    public void setBankAccount(String bankAccount) {
        this.bankAccount = bankAccount;
    }

    public String getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    public BigDecimal getPostageTotalAmount() {
        return postageTotalAmount;
    }

    public void setPostageTotalAmount(BigDecimal postageTotalAmount) {
        this.postageTotalAmount = postageTotalAmount;
    }

    public BigDecimal getOrderTotalAmount() {
        return orderTotalAmount;
    }

    public void setOrderTotalAmount(BigDecimal orderTotalAmount) {
        this.orderTotalAmount = orderTotalAmount;
    }

    public Integer getWhetherCheckAccount() {
        return whetherCheckAccount;
    }

    public void setWhetherCheckAccount(Integer whetherCheckAccount) {
        this.whetherCheckAccount = whetherCheckAccount;
    }

    public static Object[] converData(OrderMoneyRecordVo orderMoneyRecordVo){
        Object[] data = new Object[9];

        if (null != orderMoneyRecordVo) {
            //供应商名称
            data[0] = orderMoneyRecordVo.getProviderName();
            if(orderMoneyRecordVo.getCheckoutAt() != null){
                //结账时间
                data[1] = orderMoneyRecordVo.getCheckoutAt();
            }
            //待结算金额（¥）
            data[2] = NumberUtil.number2Thousand(orderMoneyRecordVo.getTotalMoney());
            //已结算金额（¥）
            data[3] = NumberUtil.number2Thousand(orderMoneyRecordVo.getSettledAmount());
            if(orderMoneyRecordVo.getSettledAt() != null) {
                //结算时间
                data[4] = orderMoneyRecordVo.getSettledAt();
            }
            //结算状态
            switch (orderMoneyRecordVo.getState()){
                case "0":
                    data[5] = "未结算";
                    break;
                case "1":
                    data[5] = "已结算";
                    break;
                default:
                    data[5] = "";
                    break;
            }
            //供应商账户
            data[6] = orderMoneyRecordVo.getBankAccount();
            //银行流水号
            data[7] = orderMoneyRecordVo.getSerialNumber();
            //是否核账
            switch (orderMoneyRecordVo.getWhetherCheckAccount()) {
                case 0:
                    data[8] = "否";
                    break;
                case 1:
                    data[8] = "是";
                    break;
                default:
                    data[8] = "";
                    break;
            }
        }
        return data;
    }
}